<link rel="stylesheet" href="/static/css/font.css">
<link rel="stylesheet" href="/static/css/xadmin.css">

<body style="overflow-x: auto;margin: 20px 20px;">
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form" method="post">
            <div class="layui-form-item">
                <label for="order_no" class="layui-form-label">
                    <span class="x-red">*</span>订单NO
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="order_no" name="order_no" required="" lay-verify="required"
                           autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>唯一订单号
                </div>
            </div>
            <div class="layui-form-item">
                <label for="user_id" class="layui-form-label">
                    <span class="x-red">*</span>用户id
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="user_id" name="user_id" required="" lay-verify="required"
                           autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>

            <div class="layui-form-item">
                <button class="layui-btn" lay-filter="add" lay-submit="">增加</button>
            </div>
        </form>
    </div>
</div>
<script>layui.use(['form', 'layer'],
    function () {
        $ = layui.jquery;
        var form = layui.form,
            layer = layui.layer;

        //监听提交
        form.on('submit(add)', function (data) {
            console.log(data);
            //发异步，把数据提交给php
            var order_no = data.field.order_no;
            var user_id = data.field.user_id;
            $.ajax({
                type: 'post',
                url: "{:url('admin/admin/admin_add')}",
                data: {order_no: order_no, user_id: user_id},
                success: function (res) {
                    layer.alert("增加成功", {
                            icon: 6
                        },
                        function () {
                            //关闭当前frame
                            xadmin.close();

                            // 可以对父窗口进行刷新
                            xadmin.father_reload();
                        });
                    //parent.layer.reload();

                }
            });
            return false;
        })
    });</script>
</body>

</html>
